package org.urchr.beorganized.dao.tables;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

@Entity
@Table(name="permissions")
//@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
public class Permission implements Serializable {

	private static final long serialVersionUID = 51949235961327534L;
	private int id;
	private Note note;
	private User user;
	private int allowCreate = 0;
	private int allowEdit = 0;
	private int allowDelete = 0;
	
	public void setId(int id) {
		this.id = id;
	}
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	public int getId() {
		return id;
	}

	public void setNote(Note note) {
		this.note = note;
	}

	@ManyToOne
	@JoinColumn(name="id_note")
	public Note getNote() {
		return note;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@ManyToOne
	@JoinColumn(name="id_user")
	public User getUser() {
		return user;
	}

	public void setAllowCreate(int allowCreate) {
		this.allowCreate = allowCreate;
	}

	@Column
	public int getAllowCreate() {
		return allowCreate;
	}

	public void setAllowEdit(int allowEdit) {
		this.allowEdit = allowEdit;
	}

	@Column
	public int getAllowEdit() {
		return allowEdit;
	}

	public void setAllowDelete(int allowDelete) {
		this.allowDelete = allowDelete;
	}

	@Column
	public int getAllowDelete() {
		return allowDelete;
	}
}
